#region Using Statements
using System;
using System.Collections.Generic;
using Graphics;
using System.Drawing;
using ImagesMath;
using ImagesMath.Transformations;
using Graphics.Geometries;
using Graphics.Films;
using System.Windows.Forms;
#endregion

namespace Graphics
{

    public class SceneController
    {
        protected Studio studio;
        protected Film film;
        protected Camera camera;
        protected int dimension;
        protected bool reflection;
        protected bool transmission;
        //private RayTracer ray;
        protected Renderer renderer;
        protected List<Object3D> scene;

        // screen constants
        protected int screenWidth = 1000;
        protected int screenHeight = 850;
        // aspect ratio for our game
        protected float m_aspect = 100;

        public SceneController()
        {
            this.reflection = false;
            this.transmission = false;
            this.dimension = 256;
            studio = new Studio();



        }

        public SceneController(int dimension,bool reflection, bool transmission)
        {
            this.reflection = reflection;
            this.transmission = transmission;
            this.dimension = dimension;
            studio = new Studio();



        }

        public bool Reflection
        {
            get { return this.reflection; }
            set { this.reflection = value; }
        }

        public bool Transmission
        {
            get { return this.transmission; }
            set { this.transmission = value; }
        }

        public void SetLight(Light light)
        {
            studio.Lights.Clear();
            studio.Lights.Add(light);
        }
        public void SetFilm(Film film)
        {
            this.film = film;
        }

        public void SetCamera(Camera camera)
        {
            studio.SetMaxDepth(4);
            //this.film = new FilmColorAna(Film.TYPE.T24x36, this.dimension, this.dimension);
            this.camera = camera;
            this.camera.SetFilm(this.film);
            this.camera.UpdateCameraTransform(camera.Position, camera.LookAt, camera.Up);
        }

        public Bitmap GetRenderImage()
        {
           return (film as FilmColorAna).GetImage();
        }

        public List<Graphics.Object3D> Objects
        {
            get { return this.studio.Objects; }
            set { this.studio.Objects = value; }
        }

        public List<Graphics.Light> Lights
        {
            get { return this.studio.Lights; }
            set { this.studio.Lights = value; }
        }

        public Camera Camera
        {
            get { return this.camera; }
            set { this.camera = value; }
        }



        public int ScreenWidth
        {
            get { return this.screenWidth; }
            //set { this.screenWidth = value; }
        }

        public int ScreenHeight
        {
            get { return this.screenHeight; }
            //set { this.screenHeight = value; }
        }

        public void Render()
        {
            this.renderer.BeginScene();
            this.renderer.Render(scene, camera);
            this.renderer.EndScene();
        }
    }
}


